package com.androwit.engine.mapping.converter.str;

import com.androwit.engine.mapping.Converter;

public class FloatConverter implements Converter<Float, String> {

	@Override
	public Float fromConverted(String value) throws Exception {
		if (value == null || value.length() == 0)
			return 0F;
		if (value.indexOf(",") != -1)
			return Float.parseFloat(value.replace(",", "."));
		else
			return Float.parseFloat(value);
	}

	@Override
	public String convert(Float value) throws Exception {
		return value.toString();
	}

}
